

// pages/repair/repair.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // name:wx.getStorageSync('name'),
    // id:wx.getStorageSync('username'),
    tel:'',
    device:'',
    number:'',
    reason:'',
    name:wx.getStorageSync('name'),
    number1:wx.getStorageSync('username')
   

  },
  gotoShow:function(imgPath){
    
    var _this=this
    wx.chooseImage({
     count: 3,
     sizeType:['original','compressed'],
     sourceType:['album','camera'],
     success:function(res){
       console.log(res)
       _this.setData({
          src:res.tempFilePaths[0]
        // src:'data:image/png;base64,'+res.data
       })
     },
    
     fail:function(){
       //fail
     },
     complete:function(){
      //  complete
     },
  //  success:res=>{
  //   wx.getFileSystemManager().readFile({
  //     filePath:res.tempFilePaths[0],
  //     encoding:'base64',
  //     success:res=>{
       
  //       console.log('data:image/png;base64,'+res.data)
  //     }
  //   })
  //  },
   
  })

  },
  // getName:function(t){
  //   this.setData({
  //     name:t.detail.value
  //   })
  //   let tm=Date.now();
  //   if((this.contentSaveTime + 500)>tm){
  //     return;
  //   }
  //   this.contentSaveTime=tm;
  // },
  // getId:function(t){
  //   this.setData({
  //     id:t.detail.value
  //   })
  //   let tm=Date.now();
  //   if((this.contentSaveTime + 500)>tm){
  //     return;
  //   }
  //   this.contentSaveTime=tm;
  // },
  getTel:function(t){
    this.setData({
      tel:t.detail.value
    })
    let tm=Date.now();
    if((this.contentSaveTime + 500)>tm){
      return;
    }
    this.contentSaveTime=tm;
  },
  getDevice:function(t){
    this.setData({
      device:t.detail.value
    })
    let tm=Date.now();
    if((this.contentSaveTime + 500)>tm){
      return;
    }
    this.contentSaveTime=tm;
  },
  getNum:function(t){
    this.setData({
      number:t.detail.value
    })
    let tm=Date.now();
    if((this.contentSaveTime + 500)>tm){
      return;
    }
    this.contentSaveTime=tm;
  },
  getReason:function(t){
    this.setData({
      reason:t.detail.value
    })
    let tm=Date.now();
    if((this.contentSaveTime + 500)>tm){
      return;
    }
    this.contentSaveTime=tm;
  },
  getImage:function(t){
    this.setData({
      picture:t.detail.value
    })
    let tm=Date.now();
    if((this.contentSaveTime + 500)>tm){
      return;
    }
    this.contentSaveTime=tm;
  },
  toMyrepair:function(){
    // wx.navigateTo({
    //   url: '../myrepair/myrepair?device='+this.data.device+'&number='+this.data.number+'&name='+this.data.name,
    // })
    wx.navigateTo({
      url: '../myfix/myfix?device='+this.data.device+'&number='+this.data.number+'&name='+this.data.name+'&id='+this.data.number1+'&tel='+this.data.tel+'&reason='+this.data.reason+'&picture='+this.data.picture,
    })
    wx.request({
      url:'https://yali.geekwhite.cn:3000/fix',
      header:{'Access-Control-Allow-Origin':'*'},
      header:{'Access-Control-Allow-Methods':'GET,POST'},
      data:{
        name:this.data.name,
        id:this.data.number1,
        tel:this.data.tel,
        device:this.data.device,
        number:this.data.number,
        reason:this.data.reason,
        // picture:res.data,
        
      },
      method:'post',
      success: function (res) {
        // console.log(data);
        console.log(res);
        
   }
    })
  },

 

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '设备保修',
    })
    this.setData({
      name:wx.getStorageSync('name'),
      number1:wx.getStorageSync('username')
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})